<?php defined('SYSPATH') or die('No direct script access.');

// Настройки
class Controller_Admin_Settings extends Controller_Admin_Base
{
	public function action_index()
	{ 
        $message = null;
               
        // Редактирование настроек
        if ($this->request->method() == HTTP_Request::POST)
        {            
            $action = $this->request->post('action');
            
            if($action == 'edit_settings')
            {                
                $settings = $this->request->post('settings') ? $this->request->post('settings') : null;
                
                if($settings)
                {
                    foreach($settings as $key => $value)
                    {
                        $this->setting_model->update_setting($value, $key);
                    }
                }
                
                $message = 'Сохранено!';
            }
        }
        
        $settings = $this->setting_model->get_settings();
        
		$title = 'Настройки';
        $content = new View('admin/settings/index_tpl');
        $content->settings = $settings;
        $content->message  = $message;
        
        
        $menu = array(
            'menu'    => 9,
            'submenu' => 90
        );
        
        $this->print_template($title, $content, $menu);
	}
} // End Admin_Settings
